﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

namespace AIC_PN
{
    public partial class MyReportViewMau8_2014 : MyFromBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                SqlConnection conn = new SqlConnection(SqlHelper.connectionString);
                SqlCommand cmd = new SqlCommand(MyReportSQL.Replace("#REPLACE#", " B.BoiDen =1 "), conn);

                for (int i = 0; i < MyReportParams.Count; i++)
                {
                    cmd.Parameters.AddWithValue(MyReportParams[i].ParameterName, MyReportParams[i].Value);
                }
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable dt = new DataTable();
                da.Fill(dt);
                grvData.DataSource = dt;
                grvData.DataBind();

                cmd = new SqlCommand(MyReportSQL.Replace("#REPLACE#", " B.BoiDen =2 "), conn);

                for (int i = 0; i < MyReportParams.Count; i++)
                {
                    cmd.Parameters.AddWithValue(MyReportParams[i].ParameterName, MyReportParams[i].Value);
                }
                SqlDataAdapter da2 = new SqlDataAdapter(cmd);
                DataTable dt2 = new DataTable();
                da2.Fill(dt2);
                grvData2.DataSource = dt2;
                grvData2.DataBind();

                cmd = new SqlCommand(MyReportSQL.Replace("#REPLACE#", " B.BoiDen =3 "), conn);

                for (int i = 0; i < MyReportParams.Count; i++)
                {
                    cmd.Parameters.AddWithValue(MyReportParams[i].ParameterName, MyReportParams[i].Value);
                }
                SqlDataAdapter da3 = new SqlDataAdapter(cmd);
                DataTable dt3 = new DataTable();
                da3.Fill(dt3);
                grvData3.DataSource = dt3;
                grvData3.DataBind();

                cmd = new SqlCommand(MyReportSQL.Replace("#REPLACE#", " B.BoiDen =4 "), conn);

                for (int i = 0; i < MyReportParams.Count; i++)
                {
                    cmd.Parameters.AddWithValue(MyReportParams[i].ParameterName, MyReportParams[i].Value);
                }
                SqlDataAdapter da4 = new SqlDataAdapter(cmd);
                DataTable dt4 = new DataTable();
                da4.Fill(dt4);
                grvData4.DataSource = dt4;
                grvData4.DataBind();

                cmd = new SqlCommand(MyReportSQL.Replace("#REPLACE#", " B.BoiDen =5 "), conn);

                for (int i = 0; i < MyReportParams.Count; i++)
                {
                    cmd.Parameters.AddWithValue(MyReportParams[i].ParameterName, MyReportParams[i].Value);
                }
                SqlDataAdapter da5 = new SqlDataAdapter(cmd);
                DataTable dt5 = new DataTable();
                da5.Fill(dt5);
                grvData5.DataSource = dt5;
                grvData5.DataBind();

                cmd = new SqlCommand(MyReportSQL.Replace("#REPLACE#", " B.BoiDen =6 "), conn);

                for (int i = 0; i < MyReportParams.Count; i++)
                {
                    cmd.Parameters.AddWithValue(MyReportParams[i].ParameterName, MyReportParams[i].Value);
                }
                SqlDataAdapter da6 = new SqlDataAdapter(cmd);
                DataTable dt6 = new DataTable();
                da5.Fill(dt6);
                grvData6.DataSource = dt6;
                grvData6.DataBind();

                cmd = new SqlCommand(MyReportSQL.Replace("#REPLACE#", " B.BoiDen =7 "), conn);

                for (int i = 0; i < MyReportParams.Count; i++)
                {
                    cmd.Parameters.AddWithValue(MyReportParams[i].ParameterName, MyReportParams[i].Value);
                }
                SqlDataAdapter da7 = new SqlDataAdapter(cmd);
                DataTable dt7 = new DataTable();
                da7.Fill(dt7);
                grvData7.DataSource = dt7;
                grvData7.DataBind();

                cmd = new SqlCommand(MyReportSQL.Replace("#REPLACE#", " B.BoiDen =8 "), conn);

                for (int i = 0; i < MyReportParams.Count; i++)
                {
                    cmd.Parameters.AddWithValue(MyReportParams[i].ParameterName, MyReportParams[i].Value);
                }
                SqlDataAdapter da8 = new SqlDataAdapter(cmd);
                DataTable dt8 = new DataTable();
                da8.Fill(dt8);
                grvData8.DataSource = dt8;
                grvData8.DataBind();

                cmd = new SqlCommand(MyReportSQL.Replace("#REPLACE#", " B.BoiDen =9 "), conn);

                for (int i = 0; i < MyReportParams.Count; i++)
                {
                    cmd.Parameters.AddWithValue(MyReportParams[i].ParameterName, MyReportParams[i].Value);
                }
                SqlDataAdapter da9 = new SqlDataAdapter(cmd);
                DataTable dt9 = new DataTable();
                da9.Fill(dt9);
                grvData9.DataSource = dt9;
                grvData9.DataBind();

                cmd = new SqlCommand(MyReportSQL.Replace("#REPLACE#", " B.BoiDen =10 "), conn);

                for (int i = 0; i < MyReportParams.Count; i++)
                {
                    cmd.Parameters.AddWithValue(MyReportParams[i].ParameterName, MyReportParams[i].Value);
                }
                SqlDataAdapter da10 = new SqlDataAdapter(cmd);
                DataTable dt10 = new DataTable();
                da10.Fill(dt10);
                grvData10.DataSource = dt10;
                grvData10.DataBind();

                cmd = new SqlCommand(MyReportSQL.Replace("#REPLACE#", " B.BoiDen =11 "), conn);

                for (int i = 0; i < MyReportParams.Count; i++)
                {
                    cmd.Parameters.AddWithValue(MyReportParams[i].ParameterName, MyReportParams[i].Value);
                }
                SqlDataAdapter da11 = new SqlDataAdapter(cmd);
                DataTable dt11 = new DataTable();
                da11.Fill(dt11);
                grvData11.DataSource = dt11;
                grvData11.DataBind();

                cmd = new SqlCommand(MyReportSQL.Replace("#REPLACE#", " B.BoiDen =12 "), conn);

                for (int i = 0; i < MyReportParams.Count; i++)
                {
                    cmd.Parameters.AddWithValue(MyReportParams[i].ParameterName, MyReportParams[i].Value);
                }
                SqlDataAdapter da12 = new SqlDataAdapter(cmd);
                DataTable dt12 = new DataTable();
                da12.Fill(dt12);
                grvData12.DataSource = dt12;
                grvData12.DataBind();

                cmd = new SqlCommand(MyReportSQL.Replace("#REPLACE#", " B.BoiDen =13 "), conn);

                for (int i = 0; i < MyReportParams.Count; i++)
                {
                    cmd.Parameters.AddWithValue(MyReportParams[i].ParameterName, MyReportParams[i].Value);
                }
                SqlDataAdapter da13 = new SqlDataAdapter(cmd);
                DataTable dt13 = new DataTable();
                da13.Fill(dt13);
                grvData13.DataSource = dt13;
                grvData13.DataBind();


                cmd = new SqlCommand(MyReportSQL.Replace("#REPLACE#", " B.BoiDen =14 "), conn);

                for (int i = 0; i < MyReportParams.Count; i++)
                {
                    cmd.Parameters.AddWithValue(MyReportParams[i].ParameterName, MyReportParams[i].Value);
                }
                SqlDataAdapter da14 = new SqlDataAdapter(cmd);
                DataTable dt14 = new DataTable();
                da14.Fill(dt14);
                grvData14.DataSource = dt14;
                grvData14.DataBind();

                cmd = new SqlCommand(MyReportSQL.Replace("#REPLACE#", " B.BoiDen =15 "), conn);

                for (int i = 0; i < MyReportParams.Count; i++)
                {
                    cmd.Parameters.AddWithValue(MyReportParams[i].ParameterName, MyReportParams[i].Value);
                }
                SqlDataAdapter da15 = new SqlDataAdapter(cmd);
                DataTable dt15 = new DataTable();
                da15.Fill(dt15);
                grvData15.DataSource = dt15;
                grvData15.DataBind();

                cmd = new SqlCommand(MyReportSQL.Replace("#REPLACE#", " B.BoiDen =16 "), conn);

                for (int i = 0; i < MyReportParams.Count; i++)
                {
                    cmd.Parameters.AddWithValue(MyReportParams[i].ParameterName, MyReportParams[i].Value);
                }
                SqlDataAdapter da16 = new SqlDataAdapter(cmd);
                DataTable dt16 = new DataTable();
                da16.Fill(dt16);
                grvData16.DataSource = dt16;
                grvData16.DataBind();

                cmd = new SqlCommand(MyReportSQL.Replace("#REPLACE#", " B.BoiDen =17 "), conn);

                for (int i = 0; i < MyReportParams.Count; i++)
                {
                    cmd.Parameters.AddWithValue(MyReportParams[i].ParameterName, MyReportParams[i].Value);
                }
                SqlDataAdapter da17 = new SqlDataAdapter(cmd);
                DataTable dt17 = new DataTable();
                da17.Fill(dt17);
                grvData17.DataSource = dt17;
                grvData17.DataBind();

                cmd = new SqlCommand(MyReportSQL.Replace("#REPLACE#", " B.BoiDen =18 "), conn);

                for (int i = 0; i < MyReportParams.Count; i++)
                {
                    cmd.Parameters.AddWithValue(MyReportParams[i].ParameterName, MyReportParams[i].Value);
                }
                SqlDataAdapter da18 = new SqlDataAdapter(cmd);
                DataTable dt18 = new DataTable();
                da18.Fill(dt18);
                grvData18.DataSource = dt18;
                grvData18.DataBind();

                cmd = new SqlCommand(MyReportSQL.Replace("#REPLACE#", " B.BoiDen =19 "), conn);

                for (int i = 0; i < MyReportParams.Count; i++)
                {
                    cmd.Parameters.AddWithValue(MyReportParams[i].ParameterName, MyReportParams[i].Value);
                }
                SqlDataAdapter da19 = new SqlDataAdapter(cmd);
                DataTable dt19 = new DataTable();
                da19.Fill(dt19);
                grvData19.DataSource = dt19;
                grvData19.DataBind();

                cmd = new SqlCommand(MyReportSQL.Replace("#REPLACE#", " B.BoiDen =20 "), conn);

                for (int i = 0; i < MyReportParams.Count; i++)
                {
                    cmd.Parameters.AddWithValue(MyReportParams[i].ParameterName, MyReportParams[i].Value);
                }
                SqlDataAdapter da20 = new SqlDataAdapter(cmd);
                DataTable dt20 = new DataTable();
                da20.Fill(dt20);
                grvData20.DataSource = dt20;
                grvData20.DataBind();

                #region Add param


                if (!MyReportSQLParam.Equals(""))
                {
                    List<SqlParameter> lstParams = new List<SqlParameter>();

                    DataTable dtParam = SqlHelper.ExecuteDataTable(CommandType.Text, MyReportSQLParam, MyReportParams);
                    if (dtParam.Rows.Count > 0)
                    {
                        //lblTenBaoCao.Text = dtParam.Rows[0]["CM_TenBaoCao"].ToString();
                        //lblDonViBaoCao.Text = dtParam.Rows[0]["TenDV"].ToString();
                        //lblNgayBaoCao.Text = dtParam.Rows[0]["CM_ThoiGianBaoCao"].ToString();
                    }
                }
                #endregion Add param

                //printReport.ReportSource = objReport;
                //printReport.DataBind();


            }
            catch (Exception ex)
            {
                Response.Write("Exception Message: " + ex.StackTrace + "<br>");
            }
        }

        public void MergeRows(GridView gridView)
        {
            for (int rowIndex = 0; rowIndex < grvData.Rows.Count - 2; rowIndex++)
            {
                GridViewRow row = grvData.Rows[rowIndex];
                GridViewRow previousRow = grvData.Rows[rowIndex + 1];

                if (row.Cells[0].Text == previousRow.Cells[0].Text)
                {
                    row.Cells[0].RowSpan = previousRow.Cells[0].RowSpan < 2 ? 2 : previousRow.Cells[0].RowSpan + 1;
                    //row.Cells[0].Visible = false;
                }
            }
        }

        #region Events

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("Index.aspx");
        }

        private static void AddMergedCells(GridViewRow objgridviewrow, TableCell objtablecell, int colspan, int rowspan, string celltext)
        {
            objtablecell = new TableCell();
            objtablecell.Text = celltext;
            objtablecell.ColumnSpan = colspan;
            objtablecell.RowSpan = rowspan;
            objtablecell.HorizontalAlign = HorizontalAlign.Center;
            objgridviewrow.Cells.Add(objtablecell);
        }
        #endregion Events

        #region GridCommand 1
        protected void grvData_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            RowDataBound(sender, e);
        }
        #endregion GridCommand 1

        #region GridCommand 2
        protected void grvData2_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            RowDataBound(sender, e);
        }
        #endregion

        #region GridCommand 3
        protected void grvData3_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            RowDataBound(sender, e);
        }
        #endregion

        #region GridCommand 4
        protected void grvData4_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            RowDataBound(sender, e);
        }
        #endregion GridCommand 1

        #region GridCommand 5
        protected void grvData5_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            RowDataBound(sender, e);
        }
        #endregion GridCommand 1

        #region GridCommand 6
        protected void grvData6_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            RowDataBound(sender, e);
        }
        #endregion GridCommand 1

        #region GridCommand 7
        protected void grvData7_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            RowDataBound(sender, e);
        }

        #endregion

        #region GridCommand 8
        protected void grvData8_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            RowDataBound(sender, e);
        }

        #endregion

        #region GridCommand 9
        protected void grvData9_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            RowDataBound(sender, e);
        }

        protected void grvData9_PreRender(object sender, EventArgs e)
        {
            MergeRows(grvData9);
        }

        protected void grvData9_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Header)
            {

                GridView objGridView = (GridView)sender;
                //GridViewRow objgridviewrow = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);

                GridViewRow objgridviewrow = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);

                TableCell objtablecell = new TableCell();
                AddMergedCells(objgridviewrow, objtablecell, 2, 1, "Cán bộ Hội");
                AddMergedCells(objgridviewrow, objtablecell, 1, 1, "Cấp ĐM");
                AddMergedCells(objgridviewrow, objtablecell, 1, 1, "Cấp CS");
                objgridviewrow.Font.Bold = true;
                objGridView.Controls[0].Controls.AddAt(0, objgridviewrow);
            }
        }
        #endregion

        #region GridCommand 10
        protected void grvData10_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            RowDataBound(sender, e);
        }

        protected void grvData10_PreRender(object sender, EventArgs e)
        {
            MergeRows(grvData10);
        }

        protected void grvData10_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Header)
            {

                GridView objGridView = (GridView)sender;
                //GridViewRow objgridviewrow = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);

                GridViewRow objgridviewrow = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);

                TableCell objtablecell = new TableCell();
                AddMergedCells(objgridviewrow, objtablecell, 2, 1, "CB Hội DTTS	");
                AddMergedCells(objgridviewrow, objtablecell, 1, 1, "Cấp ĐM");
                AddMergedCells(objgridviewrow, objtablecell, 1, 1, "Cấp CS");
                objgridviewrow.Font.Bold = true;
                objGridView.Controls[0].Controls.AddAt(0, objgridviewrow);
            }
        }
        #endregion

        #region GridCommand 11
        protected void grvData11_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            RowDataBound(sender, e);
        }
        #endregion

        #region GridCommand 12
        protected void grvData12_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            RowDataBound(sender, e);
        }

        protected void grvData12_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Header)
            {

                GridView objGridView = (GridView)sender;
                //GridViewRow objgridviewrow = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);

                GridViewRow objgridviewrow = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);
                GridViewRow objgridviewrow2 = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);

                TableCell objtablecell = new TableCell();
                AddMergedCells(objgridviewrow, objtablecell, 1, 2, "Danh mục");
                AddMergedCells(objgridviewrow, objtablecell, 3, 1, "Lĩnh vực");
                objgridviewrow.Font.Bold = true;
                objGridView.Controls[0].Controls.AddAt(0, objgridviewrow);

                objtablecell = new TableCell();
                AddMergedCells(objgridviewrow2, objtablecell, 1, 1, "Đảng");
                AddMergedCells(objgridviewrow2, objtablecell, 1, 1, "Chính quyền");
                AddMergedCells(objgridviewrow2, objtablecell, 1, 1, "Các đoàn thể khác");
                objgridviewrow2.Font.Bold = true;
                objGridView.Controls[0].Controls.AddAt(1, objgridviewrow2);
            }
        }
        #endregion

        #region GridCommand 13
        protected void grvData13_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            RowDataBound(sender, e);
        }
        #endregion

        #region GridCommand 14
        protected void grvData14_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            RowDataBound(sender, e);
        }
        #endregion

        #region GridCommand 15
        protected void grvData15_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            RowDataBound(sender, e);
        }
        #endregion

        #region GridCommand 16
        protected void grvData16_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            RowDataBound(sender, e);
        }

        protected void grvData16_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Header)
            {

                GridView objGridView = (GridView)sender;
                //GridViewRow objgridviewrow = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);

                GridViewRow objgridviewrow = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);
                GridViewRow objgridviewrow2 = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);

                TableCell objtablecell = new TableCell();
                AddMergedCells(objgridviewrow, objtablecell, 1, 2, "Nội dung");
                AddMergedCells(objgridviewrow, objtablecell, 2, 1, "Cấp đầu mối");
                AddMergedCells(objgridviewrow, objtablecell, 3, 1, "Cấp cơ sở");
                objgridviewrow.Font.Bold = true;
                objGridView.Controls[0].Controls.AddAt(0, objgridviewrow);

                objtablecell = new TableCell();
                AddMergedCells(objgridviewrow2, objtablecell, 1, 1, "Tổ chức Hội");
                AddMergedCells(objgridviewrow2, objtablecell, 1, 1, "Cán bộ Hội");
                AddMergedCells(objgridviewrow2, objtablecell, 1, 1, "Tổ chức Hội");
                AddMergedCells(objgridviewrow2, objtablecell, 1, 1, "Cán bộ Hội");
                AddMergedCells(objgridviewrow2, objtablecell, 1, 1, "Hội viên");
                objgridviewrow2.Font.Bold = true;
                objGridView.Controls[0].Controls.AddAt(1, objgridviewrow2);
            }
        }
        #endregion

        #region GridCommand 17
        protected void grvData17_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            RowDataBound(sender, e);
        }
        #endregion

        #region GridCommand 18
        protected void grvData18_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            RowDataBound(sender, e);
        }

        protected void grvData18_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Header)
            {

                GridView objGridView = (GridView)sender;
                //GridViewRow objgridviewrow = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);

                GridViewRow objgridviewrow = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);
                GridViewRow objgridviewrow2 = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);

                TableCell objtablecell = new TableCell();
                AddMergedCells(objgridviewrow, objtablecell, 1, 2, "Thành tích khen thưởng");
                AddMergedCells(objgridviewrow, objtablecell, 2, 1, "Cấp  Đầu mối TT Bộ");
                AddMergedCells(objgridviewrow, objtablecell, 2, 1, "Cấp cơ sở");
                objgridviewrow.Font.Bold = true;
                objGridView.Controls[0].Controls.AddAt(0, objgridviewrow);

                objtablecell = new TableCell();
                AddMergedCells(objgridviewrow2, objtablecell, 1, 1, "Tập thể");
                AddMergedCells(objgridviewrow2, objtablecell, 1, 1, "Cá nhân");
                AddMergedCells(objgridviewrow2, objtablecell, 1, 1, "Tập thể");
                AddMergedCells(objgridviewrow2, objtablecell, 1, 1, "Cá nhân");
                objgridviewrow2.Font.Bold = true;
                objGridView.Controls[0].Controls.AddAt(1, objgridviewrow2);
            }
        }
        #endregion

        #region GridCommand 19
        protected void grvData19_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            RowDataBound(sender, e);
        }

        protected void grvData19_PreRender(object sender, EventArgs e)
        {
            MergeRows(grvData19);
        }

        protected void grvData19_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Header)
            {

                GridView objGridView = (GridView)sender;
                //GridViewRow objgridviewrow = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);

                GridViewRow objgridviewrow = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);
                GridViewRow objgridviewrow2 = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);

                TableCell objtablecell = new TableCell();
                AddMergedCells(objgridviewrow, objtablecell, 1, 2, "STT");
                AddMergedCells(objgridviewrow, objtablecell, 1, 2, "Tên mô hình");
                AddMergedCells(objgridviewrow, objtablecell, 1, 1, "Cấp thực hiện");
                AddMergedCells(objgridviewrow, objtablecell, 1, 1, "Số lượng");
                AddMergedCells(objgridviewrow, objtablecell, 1, 2, "Phạm vi triển khai mô hình (tổng số cơ sở Hội có mô hình)");
                objgridviewrow.Font.Bold = true;
                objGridView.Controls[0].Controls.AddAt(0, objgridviewrow);

                objtablecell = new TableCell();
                AddMergedCells(objgridviewrow2, objtablecell, 1, 1, "(ĐM/cơ sở)");
                AddMergedCells(objgridviewrow2, objtablecell, 1, 1, "(CLB, tổ…)/tổng số thành viên");
                objgridviewrow2.Font.Bold = true;
                objGridView.Controls[0].Controls.AddAt(1, objgridviewrow2);
            }
        }
        #endregion

        #region GridCommand 20
        protected void grvData20_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            RowDataBound(sender, e);
        }

        protected void grvData20_PreRender(object sender, EventArgs e)
        {
            MergeRows(grvData20);
        }

        protected void grvData20_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Header)
            {

                GridView objGridView = (GridView)sender;
                //GridViewRow objgridviewrow = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);

                GridViewRow objgridviewrow = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);
                GridViewRow objgridviewrow2 = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);

                TableCell objtablecell = new TableCell();
                AddMergedCells(objgridviewrow, objtablecell, 1, 2, "Cấp");
                AddMergedCells(objgridviewrow, objtablecell, 1, 2, "Tổng số");
                AddMergedCells(objgridviewrow, objtablecell, 6, 1, "Tên mô hình mới tập hợp thu hút hội viên");
                objgridviewrow.Font.Bold = true;
                objGridView.Controls[0].Controls.AddAt(0, objgridviewrow);

                objtablecell = new TableCell();
                AddMergedCells(objgridviewrow2, objtablecell, 1, 1, "Nữ thanh niên");
                AddMergedCells(objgridviewrow2, objtablecell, 1, 1, "Dân tộc");
                AddMergedCells(objgridviewrow2, objtablecell, 1, 1, "Tôn giáo");
                AddMergedCells(objgridviewrow2, objtablecell, 1, 1, "Nữ trí thức");
                AddMergedCells(objgridviewrow2, objtablecell, 1, 1, "LĐ nữ khu CN, CX");
                AddMergedCells(objgridviewrow2, objtablecell, 1, 1, "Mô hình ");
                objgridviewrow2.Font.Bold = true;
                objGridView.Controls[0].Controls.AddAt(1, objgridviewrow2);
            }
        }
        #endregion
    }
}
